package com.tianxiang.action;

import java.util.ArrayList;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.json.annotations.JSON;

import com.opensymphony.xwork2.ActionSupport;
import com.tianxiang.model.Node;
import com.tianxiang.model.User;
import com.tianxiang.service.ShowTreeService;
import com.tianxiang.utils.Tools;

public class ShowTreeAction extends ActionSupport {
	private String node;		//接收节点传来的目录请求
	ArrayList<Node>nodesList;	//返回的节点列表
	@JSON(serialize=false)//serialize参数为false，不会被序列化
	public String getNode() {
		return node;
	}

	public void setNode(String node) {
		this.node = node;
	}

	public ArrayList<Node> getNodesList() {
		return nodesList;
	}

	public void setNodesList(ArrayList<Node> nodesList) {
		this.nodesList = nodesList;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String execute() {
			User user=(User)ServletActionContext.getRequest().getSession()
					.getAttribute("loginuser");
	String username=user.getUsername();
		ShowTreeService showTreeService=new ShowTreeService();
		String currentFolder = Tools.getAcessPath(username,getNode(),"");
		System.err.println("tree请求的currentFolder="+currentFolder);
		nodesList=showTreeService.getNodes(username,currentFolder);
		return SUCCESS;
	}
	
}
